package com.naiyumie.ncalculator;

import com.naiyumie.nlib.Nlog;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class HelperActivity extends Activity {
	
	TextView tvHelperTitle = null;
	TextView tvHelperText = null;
	String msg = null;
	Nlog nlog = new Nlog();
	TextView tvTitle = null;
	Button prevBtn = null;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_helper);
		
		prevBtn = (Button) findViewById(R.id.prevBtn);
		prevBtn.setOnClickListener(helperTitleBarAction);
		
		tvTitle = (TextView) findViewById(R.id.tvTitle);
		tvTitle.setText(R.string.helper_app);
		tvTitle.setOnClickListener(helperTitleBarAction);
		
		Intent fromIntent = getIntent();
		msg = fromIntent.getStringExtra("MSG").toString();
		
		String idTitle = msg.toString() + "_title";
		int helpTitle = getResources().getIdentifier(idTitle, "string", this.getPackageName());
		String helpTitleText = getResources().getString(helpTitle);
		tvHelperTitle = (TextView) findViewById(R.id.tvHelperTitle);
		tvHelperTitle.setText(helpTitleText);

		String txtTitle = msg.toString();
		int helpText = getResources().getIdentifier(txtTitle, "string", this.getPackageName());
		String helpTextText = getResources().getString(helpText);
		tvHelperText = (TextView) findViewById(R.id.tvHelperText);
		tvHelperText.setText(helpTextText);
		
		//nlog.puts("msg > " + msg);
		//nlog.puts("helpTitle > " + helpTitle);
		//nlog.puts("helpTitleText > " + helpTitleText);
		//nlog.puts("helpText > " + helpText);
		//nlog.puts("helpTextText > " + helpTextText);
	}
	
	View.OnClickListener helperTitleBarAction = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			nlog.puts("click action2 > " + v.getId());
			switch (v.getId()) {
				case R.id.prevBtn:
				case R.id.tvTitle:
					HelperActivity.this.finish();
					break;
				default:
					break;
			}
		}
	};
}
